<%--
  Created by IntelliJ IDEA.
  User: ASUS
  Date: 2021/9/8
  Time: 14:23
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
    <h1>修改信息</h1>
    <form action="" method="post">
        编号：<input type="text" name="id" readonly value="${student.id}"><br>
        姓名：<input type="text" name="name" value="${student.name}"><br>
        年龄：<input type="text" name="age" value="${student.age}"><br>
        性别：<input type="text" name="gender" value="${student.gender}"><br>
        <input type="submit" value="修改">
    </form>
    <hr>

    <!--
        下面用 spring mvc 的表单标签绑定业务数据，与上面的效果是一样的
        但是更加方便，而且如果需要进行表单数验证，就必须用 spring mvc 的表单标签库
        提交也能在 Handler 中获取到数据
        需要先引入
     -->
    <form:form modelAttribute="student" action="${pageContext.request.contextPath}/student/update" method="post">
        编号：<form:input path="id"></form:input><br>
        姓名：<form:input path="name"></form:input><br>
        密码：<form:password path="password"></form:password><br>
        年龄：<form:input path="age"></form:input><br>
        性别：<form:input path="gender"></form:input><br>
        地址：<form:input path="address.name"></form:input><br>
        checkbox:<form:checkbox path="flag" value="1"></form:checkbox><br>
        <form:checkbox path="selectHobby" value="读书"></form:checkbox>  读书 <br>
        <form:checkbox path="selectHobby" value="看电影"></form:checkbox> 看电影<br>
        <form:checkbox path="selectHobby" value="旅行"></form:checkbox>  旅行 <br>
        <form:checkbox path="selectHobby" value="散步"></form:checkbox>  散步 <br>
        <form:checkbox path="selectHobby" value="打游戏"></form:checkbox> 打游戏 <br>
        <form:checkbox path="selectHobby" value="打篮球"></form:checkbox> 打篮球 <br>
        <%--
            checkboxes 一个标签能实现上面的功能，
            items 用 EL 表达式去取
            path 直接绑定业务数据
        --%>
        <hr>
        <form:checkboxes path="selectHobby" items="${student.hobby}"></form:checkboxes> <br>
        <form:radiobutton path="radioId" value="1"></form:radiobutton> 男 <br>
        <form:radiobutton path="radioId" value="0"></form:radiobutton> 女 <br>
        <%-- 与 checkboxes 类似的标签 radiobuttons --%>
        <form:radiobuttons path="selectGrade" items="${student.gradeMap}"></form:radiobuttons> <br>

        <%--   select 的多种用法     --%>
<%--        <form:select path="selectCity" items="${student.cityMap}"></form:select> <br>--%>

<%--        <form:select path="selectCity">--%>
<%--            <form:options items="${student.cityMap}"></form:options> <br>--%>
<%--        </form:select>--%>

        <form:select path="selectCity">
            <form:option value="1">广州</form:option>
            <form:option value="2">西安</form:option>
            <form:option value="3">成都</form:option>
        </form:select> <br>
        <input type="submit" value="修改">
    </form:form>
</body>
</html>
